package com.chenhs.oop.study.时间类;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * @program: JAVA300
 * @description: 可视化日历程序
 * @author: peanut
 * @create: 2018-12-28 21:40
 */
public class TtestCalendar {


    public static void main(String[] args) throws ParseException {
        String str="2018-12-28";
//        Calendar c = new Calendar();
        SimpleDateFormat sb = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = sb.parse(str);
        Calendar c = new GregorianCalendar();
        c.setTime(parse);
       /* 返回当天是该月的第几天*/
        c.set(Calendar.DAY_OF_MONTH,29);
        System.out.println("日\t一\t二\t三\t四\t五\t六");

        for (int i = 0; i <c.get(Calendar.DAY_OF_WEEK)-1 ; i++) {
            System.out.print("\t");
        }

        for (int i = 0; i <30; i++) {
            System.out.print(c.get(Calendar.DAY_OF_MONTH)+"\t");

           /* 返回当前日期是当月中的第几天  */
            if(c.get(Calendar.DAY_OF_WEEK) ==Calendar.SATURDAY){
                System.out.println();
            }
            /* 日期加一天*/
            c.add(Calendar.DAY_OF_MONTH,
                    61);
        }
        System.out.println("完美");
    }


}
